﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Inner.Master"
    CodeBehind="AppointmentsList.aspx.vb" Inherits="LecturerAppointmentSystem.Appointments" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <asp:Label ID="lbl_TodaysDate" runat="server" CssClass="hideControl"></asp:Label>
    <br />
    <br />
    <asp:Label ID="lbl_msg" runat="server" 
        Text="Please click on manage to cancel or reschedule an appointment" 
        Visible="False"></asp:Label>
    <br />
    <asp:MultiView ID="AppointmentsMultiView" runat="server">
        <asp:View ID="LecturerView" runat="server">
        <center>
            <asp:GridView ID="LecturerGridView" runat="server" AutoGenerateColumns="False" DataSourceID="LecturerAppointmentDetailsDataSource"
                EnableModelValidation="True" AllowPaging="True" AllowSorting="True" 
                CellPadding="4" ForeColor="#333333" GridLines="None" Width="70%">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:BoundField DataField="AppointmentDate" HeaderText="Date" SortExpression="AppointmentDate"
                        DataFormatString="{0:d}" />
                    <asp:BoundField DataField="TimeSlot" HeaderText="Time" SortExpression="TimeSlot" />
                    <asp:BoundField DataField="Place" HeaderText="Place" SortExpression="Place" />
                    <asp:BoundField DataField="Agenda" HeaderText="Agenda" SortExpression="Agenda" />
                    <asp:TemplateField HeaderText="Booked By" SortExpression="Student_FirstName">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Student_FirstName") & " " & Eval("Student_LastName") %>'></asp:Label></ItemTemplate>
                    </asp:TemplateField>
                    <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="AppointmentDetails.aspx?ID={0}"
                        Text="Manage" />
                    <asp:BoundField HeaderText="AppointmentId" Visible="False" />
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <EmptyDataTemplate>
                    You have no upcoming appointments.
                </EmptyDataTemplate>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            </asp:GridView>
            <asp:SqlDataSource ID="LecturerAppointmentDetailsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>"
                ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>"
                SelectCommand="SELECT * FROM [AppointmentsWithLecturerAndStudentDetails] WHERE ([Lecturer_Fkid_UserId] = ?) AND ([AppointmentDate] >= ?)">
                <SelectParameters>
                    <asp:QueryStringParameter Name="Lecturer_Fkid_UserId" QueryStringField="UserId" Type="Int32" />
                    <asp:ControlParameter ControlID="lbl_TodaysDate" Name="AppointmentDate" PropertyName="Text"
                        Type="DateTime" />
                </SelectParameters>
            </asp:SqlDataSource>
            </center>
        </asp:View>
        <asp:View ID="StudentView" runat="server">
            <center>
                <asp:LinkButton ID="lb_BookAppointment" runat="server" PostBackUrl="~/BookAppointment.aspx">Book a new appointment</asp:LinkButton>
                <br />
                <asp:GridView ID="StudentGridView" runat="server" AutoGenerateColumns="False" DataSourceID="StudentAppointmentDetailsDataSource"
                    EnableModelValidation="True" AllowPaging="True" AllowSorting="True" 
                    Width="70%" CellPadding="4" ForeColor="#333333" GridLines="None">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:BoundField DataField="AppointmentDate" HeaderText="Date" SortExpression="AppointmentDate"
                            DataFormatString="{0:d}" />
                        <asp:BoundField DataField="TimeSlot" HeaderText="Time" SortExpression="TimeSlot" />
                        <asp:BoundField DataField="Place" HeaderText="Place" SortExpression="Place" />
                        <asp:BoundField DataField="Agenda" HeaderText="Agenda" SortExpression="Agenda" />
                        <asp:TemplateField HeaderText="Lecturer" SortExpression="Lecturer_FirstName">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Lecturer_FirstName") & " " & Eval("Lecturer_LastName") %>'></asp:Label></ItemTemplate>
                        </asp:TemplateField>
                        <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="AppointmentDetails.aspx?ID={0}"
                            Text="Manage" />
                        <asp:BoundField HeaderText="AppointmentId" Visible="False" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <EmptyDataTemplate>
                    <center>
                        You have no upcoming appointments.
                        </center>
                    </EmptyDataTemplate>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                </asp:GridView>
                <br />
                <asp:SqlDataSource ID="StudentAppointmentDetailsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>"
                    SelectCommand="SELECT * FROM [AppointmentsWithLecturerAndStudentDetails] WHERE ([Student_Fkid_UserId] = ?) AND ([AppointmentDate] &gt;= ?)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Student_Fkid_UserId" QueryStringField="UserId" Type="Int32" />
                        <asp:ControlParameter ControlID="lbl_TodaysDate" Name="AppointmentDate" PropertyName="Text"
                            Type="DateTime" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </center>
        </asp:View>
    </asp:MultiView>
</asp:Content>
